//
//  AllDDView.m
//  YYZB
//
//  Created by BY_R on 16/3/31.
//
//

#import "AllDDView.h"

@implementation AllDDView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(id)initWithFrame:(CGRect)frame{
    if (self) {
        self = [super initWithFrame:frame];
    }
    self.tableview = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 90, 150) style:UITableViewStylePlain];
    self.tableview.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.tableview.showsHorizontalScrollIndicator = NO;
    self.tableview.showsVerticalScrollIndicator = NO;
    self.tableview.dataSource = self;
    self.tableview.delegate = self;
    self.tableview.layer.cornerRadius = 3;
    
    self.tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self addSubview:self.tableview];
    self.getservice = [GetService new];
    
    [self.getservice getService:^(NSArray *items, NSError *error) {
        self.dataArray = [items valueForKey:@"CategoryName"];
        [self.tableview reloadData];
    }];
    
    [self.getservice getsmallService:^(NSArray * items, NSError * error) {
        
    }];
    return self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = self.dataArray[indexPath.row];
    [cell.textLabel setFont:[UIFont systemFontOfSize:14]];
    cell.textLabel.textColor = [UIColor lightGrayColor];
    
    return cell;
}
@end
